package cn.ylg.com.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by MyPC on 2016/10/20.
 */
public class SudentDBOpenHelper extends SQLiteOpenHelper {

    private static String DBName = "tz_class";
    //数据类型
    private static final String TEXT_TYPE = " TEXT";//不管数据的长度
    private static final String VARCHAR_TYPE = " VARCHAR(255)";//字符创
    private static final String INTEGER_TYPE = " INT ";
    private static final String COMMA_SEP = ",";
    private static final String DATETIME_TYPE = "DATE_TIME";
    public final static String table_create ="" +
            "CREATE TABLE "+StudentContract.StudentEntry.TABLE_NAME+" ( " +
            StudentContract.StudentEntry._ID +" "+INTEGER_TYPE+"  auto_increment"+COMMA_SEP
            + " "+ StudentContract.StudentEntry.COLUMN_NAME_ENTRY+" "+VARCHAR_TYPE+" NOT NULL"+COMMA_SEP+
            " "+ StudentContract.StudentEntry.COLUMN_AGE+" "+INTEGER_TYPE+" NOT NULL"+COMMA_SEP+
            " "+ StudentContract.StudentEntry.COLUMN_START_CLASS+" "+DATETIME_TYPE+")";

    public SudentDBOpenHelper(Context context) {
        super(context, DBName, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //执行语句
        db.execSQL(table_create);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
